package com.example.sharding.controller;

import com.example.sharding.manager.IOrderManager;
import com.example.sharding.model.OrderModel;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 刘房
 * @Description: 测试业务数据
 * @date 2020/9/3 10:16
 */
@Api
@RestController
public class OrderController {

    @Autowired
    private IOrderManager orderManager;

    @PostMapping("/save")
    public boolean save(@RequestBody OrderModel orderModel){
        try{
            orderManager.save(orderModel);
            return true;
        }catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    @GetMapping("/findAll")
    public List<OrderModel> findAll(){
        return orderManager.findAll();
    }
}
